The present invention relates to a flash memory device.
A flash memory device manages a memory region in blocks to shorten the time for reading data (refer to, for example, Japanese Laid-Open Patent Publication No. 9-134312). A block management value is added to each block. The block management value is information indicating whether the corresponding block is in a used state (active state) or unused state.
As shown in the example of FIG. 6, a block management value is formed by hexadecimal numbers arranged as four digits. More specifically, “$1111” is allocated as the block management value in an active state, and “$FFFF” is allocated as the block management value in a non-used state. In the description hereafter, values following “$” are hexadecimal numbers.
In detail, referring to FIG. 7, cells 10, which can be charged and discharged, are used to express the four digits of the block management value. Each cell 10 stores a single bit that is “0” when the accumulated charge is greater than or equal to a threshold Th and “1” when the accumulated charge is less than the threshold Th.
Referring to FIG. 8, four digital values of “0” or “1” obtained by the four cells 10, that is, a four-digit binary number, are used to express each of the hexadecimal digits.
A flash memory device will now be described with reference to the upper part of FIG. 6, which shows a first block in an active state and a second block in an unused state. The two blocks each include first to nth data areas A1 to An, which store data. Here, n represents a natural number. The data areas A1 to An in the unused second block are all empty and do not include data. When there is a write request for data (updated value), updated values are sequentially written to the first to nth data areas A1 to An of the first block. This reduces the empty data areas. Then, as shown in the lower part of FIG. 6, when an updated value is written to the nth data area An of the first block, the block management value of the second block is rewritten from “$FFFF”, which indicates an unused state, to “$1111”, which indicates an active state, and the updated value is copied to the first data area A1 of the second block. Subsequently, the data stored in the first block is completely erased, and the block management value is rewritten from “$1111”, which indicates the active state to “$FFFF”, which indicates the unused state. This processing is referred to as maintenance.
When an updated value is copied, the updated value may be renewed. In this case, the renewed updated value is written to the first data area A1 of the second block.
When an updated value is copied from the first block to the second block, the flash memory device may be reset when its power supply is temporarily deactivated. In this case, the first block is not switched to an unused state. Thus, when the power supply is activated again during the resetting, two blocks would be in an active state, and the updated value becomes unknown. In particular, during the copying of an updated value, renewal of the updated value would result in the updated values of the first and second blocks being different data. In this case, the true updated value is that of the second block. However, there is no means to recognize the true updated value. This may result in updated value being erroneously read from the first block.
To solve this problem, the use of serial numbers for block management values indicating active states has been discussed. More specifically, a block management value of “$1111” is allocated to the first block when the first block is in an active state. Then, a block management value of “$1112” is allocated to the second block when the second block is in an active state.
As a result, even when there are two blocks that are in active states due to a reset, the true updated value can be read from the block with the largest block management value (in this example, “$1112”).
In this configuration, the maintenance described above is performed after the updated value is copied to the second block. More specifically, as shown in FIG. 9(a), the first block management value indicating an active state is rewritten to indicate an unused state. That is, the first block management value of “$0001” is rewritten to “$FFFF”. Here, the cells 10 are all discharged to obtain the block management value of “$FFFF”. However, the cells 10 are not discharged at the same speed. Thus, the cells 10 store the digital values of “1” in a random order. For example, referring to FIG. 9(b), among the four cells 10 corresponding to hexadecimal “1” (first digit), the cell 10 for the second digit may be the fastest one to store the digital value of “1”. In this case, when a reset occurs as soon as the cell 10 for the second digit stores the digital value of “1”, the bits of the four cells 10 would express the digital value of “0011”, which would be “3” instead of “1” in the hexadecimal system. Thus, the block management value would be “$0003”. Here, the block management value of “$0003” for the first block would be greater than the block management value of “$0002” for the second block. Accordingly, the updated value would be read from the first block when maintenance is performed, and the true updated value cannot be read.